home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 730 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. From: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
  2. Message-ID: <4iaj1v$2dj@mulga.cs.mu.OZ.AU>
  3. X-Original-Date: 15 Mar 1996 02:01:35 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 15 Mar 96 02:03:39 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Access to private base class?
  9. Organization: Comp Sci, University of Melbourne
  10. References: <4ia9bj$atj@ugress.uib.no>
  11. Keywords: C++, private class
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMUjQCOEDnX0m9pzZAQGg1wF+OFtXXKugrBAp3ldBZMMvtaQEM8tgXwXw
  14.     QGSkNR872r5FbLaewYlxss+jkydPJRDX
  15.     =8/to
  16.  
  17. boukanov@sentef1.fi.uib.no (Igor Boukanov) writes:
  18.  
  19. >Here the lines from September DWP, 5.2.6.9:
  20. >
  21. >class D : public virtual A, private B {};
  22. >void g()
  23. >{
  24. >    D   d;
  25. >    B*  bp = (B*)&d;  // cast needed to break protection
  26. >...
  27. >
  28. >Does "cast needed to break protection" mean that in this case it is possible 
  29. >to get access to the private base class by simple cast expression? 
  30.  
  31. Yes.
  32.  
  33. From Stroustrup's book Design and Evolution of C++, page 328:
  34. "The fact that an old-stype cast can be used to gain access to the part of a
  35. representation that is a private base is an unfortunate historical accident."
  36.  
  37. --
  38. Fergus Henderson                 WWW: http://www.cs.mu.oz.au/~fjh
  39. fjh@cs.mu.oz.au                  PGP: finger fjh@128.250.37.3
  40. ---
  41. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  42. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  43. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  44. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  45. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  46.